package gandalf.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.servlet.http.HttpServletRequest;

@Entity
public class Stranka implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String ime;
    private String priimek;
    private String naslov;
    private String kraj;
    private boolean narocen;
    private String email;
    @OneToMany(mappedBy = "stranka", cascade = CascadeType.ALL)
    private List<Rezervacija> rezervacije;
    @OneToMany(cascade = CascadeType.MERGE)
    private List<Nakup> nakupi;
    private String password;

    /**
     * Get the value of password
     *
     * @return the value of password
     */
    public String getPassword() {
        return password;
    }

    /**
     * Set the value of password
     *
     * @param password new value of password
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * Get the value of kraj
     *
     * @return the value of kraj
     */
    public String getKraj() {
        return kraj;
    }

    /**
     * Set the value of kraj
     *
     * @param kraj new value of kraj
     */
    public void setKraj(String kraj) {
        this.kraj = kraj;
    }

    /**
     * Get the value of nakupi
     *
     * @return the value of nakupi
     */
    public List<Nakup> getNakupi() {
        return nakupi;
    }

    /**
     * Set the value of nakupi
     *
     * @param nakupi new value of nakupi
     */
    public void setNakupi(List<Nakup> nakupi) {
        this.nakupi = nakupi;
    }

    /**
     * Get the value of rezervacije
     *
     * @return the value of rezervacije
     */
    public List<Rezervacija> getRezervacije() {
        return rezervacije;
    }

    /**
     * Set the value of rezervacije
     *
     * @param rezervacije new value of rezervacije
     */
    public void setRezervacije(List<Rezervacija> rezervacije) {
        this.rezervacije = rezervacije;
    }

    /**
     * Get the value of email
     *
     * @return the value of email
     */
    public String getEmail() {
        return email;
    }

    /**
     * Set the value of email
     *
     * @param email new value of email
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * Get the value of narocen
     *
     * @return the value of narocen
     */
    public boolean isNarocen() {
        return narocen;
    }

    /**
     * Set the value of narocen
     *
     * @param narocen new value of narocen
     */
    public void setNarocen(boolean narocen) {
        this.narocen = narocen;
    }

    /**
     * Get the value of naslov
     *
     * @return the value of naslov
     */
    public String getNaslov() {
        return naslov;
    }

    /**
     * Set the value of naslov
     *
     * @param naslov new value of naslov
     */
    public void setNaslov(String naslov) {
        this.naslov = naslov;
    }

    /**
     * Get the value of priimek
     *
     * @return the value of priimek
     */
    public String getPriimek() {
        return priimek;
    }

    /**
     * Set the value of priimek
     *
     * @param priimek new value of priimek
     */
    public void setPriimek(String priimek) {
        this.priimek = priimek;
    }

    /**
     * Get the value of ime
     *
     * @return the value of ime
     */
    public String getIme() {
        return ime;
    }

    /**
     * Set the value of ime
     *
     * @param ime new value of ime
     */
    public void setIme(String ime) {
        this.ime = ime;
    }

    /**
     * Get the value of id
     *
     * @return the value of id
     */
    public Long getId() {
        return id;
    }

    /**
     * Set the value of id
     *
     * @param id new value of id
     */
    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "gandalf.model.Stranka[id=" + id + "]";
    }

    public void setAttributes(HttpServletRequest request) {
        ime = request.getParameter("ime");
        priimek = request.getParameter("priimek");
        naslov = request.getParameter("naslov");
        kraj = request.getParameter("kraj");
        email = request.getParameter("email");
        password = request.getParameter("password");
        narocen = request.getParameter("narocen") != null ? true : false;
    }
}
